function [m, n_id, mi_flav2_ind] = gen_micro_moment(id, q, dummy, ...
    price, income, weights, cutoff, cutoff_craft_inc, id_boot)

[~, ~, id0] = unique(id);

sum1 = @(x) sum(x, 1);

ttq = grpstats(q, id0, sum1);
ind1 = ttq>=1;
ind_keep = ind1(id0);

% keep household/year/mkt combinations with beer purchase
id = id(ind_keep); 
q = q(ind_keep);
dummy = dummy(ind_keep, :); 
price = price(ind_keep, :);
income = income(ind_keep, :);
weights = weights(ind_keep, :);

[~, ~, id0] = unique(id);

n_id = max(id0);

[m, mi_flav2_ind] = gen_micro_moment_i(id0, q, dummy, ...
    price, income, weights, cutoff, cutoff_craft_inc, id_boot);

